import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:note/common/common.dart';
import 'package:note/manager/global.dart';
import 'package:note/widgets/BasePage.dart';

import '../../widgets/buttons.dart';
import 'logic.dart';

class SetLockPage extends StatelessWidget {
  SetLockPage({Key? key}) : super(key: key);

  final logic = Get.put(SetLockLogic());
  final state = Get.find<SetLockLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('设备锁'),
        backgroundColor: Styles.backgroundColor,
        foregroundColor: Styles.mainThemeColor,
      ),
      body: BasePage(
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Obx(() => Icon(
                    GlobalUtil.appSet.value.isLocked
                        ? Icons.lock_outline_rounded
                        : Icons.lock_open,
                    color: Styles.mainThemeColor,
                    size: 50,
                  )),
              const SizedBox(height: 20),
              Obx(() {
                return DefaultTextButton(
                    text: GlobalUtil.appSet.value.isLocked ? '解锁App' : '上锁App',
                    function: logic.onLockApp);
              }),
            ],
          ),
        ),
      ),
    );
  }
}
